﻿using System;

namespace FDEE.Model
{
    /// <summary>
    /// 标准弯钩
    /// </summary>
    public class MRORebarRecord : RebarBase
    {
        //public int A, B,r,Lx;

        /// <summary>
        /// 标准箍筋
        /// </summary>
        /// <param name="mBarMark"></param>
        /// <param name="sBarMark"></param>
        /// <param name="cBarMark"></param>
        /// <param name="diameter"></param>
        /// <param name="quantity"></param>
        /// <param name="shapeConfig"></param>
        /// <param name="a">内侧距离A</param>
        /// <param name="b">内侧距离B</param>
        /// <param name="rr">内半径，默认为0时，按规范取值</param>
        public MRORebarRecord(int mBarMark, int sBarMark, string cBarMark, eDB diameter,int quantity,eShapeType shapeConfig,
            int a, int b,int c,int rr=0):base(mBarMark,sBarMark,cBarMark,diameter,quantity,shapeConfig)
        {
            if(a<0||b<0||Lx<0)
            {
                throw new Exception("箍筋结果异常请查询原因！");
            }
            A = a;
            B = b;
            C = c;
            this.d = PublicEnumItems.GeteDBData(diameter.ToString());
            if (rr==0)
            {
                r = RebarKnowledge.GetRadiusForSrirrup(diameter);
            }
            else
            {
                r = rr;
            }
            Lx = RebarKnowledge.GetLxNew(diameter);
            this.Formula = "L=2(A+2B+C)+Lx";
        }

        public override void SetLength()
        {
            //Length=(2 * (A + B) + Lx)*0.001;
            Length = Math.Round((2 * (A + 2*B+C) + Lx) * 0.001, 3, MidpointRounding.AwayFromZero);
        }
    }
    public class MRRebarRecord : RebarBase
    {
        //public int A, B,r,Lx;

        /// <summary>
        /// 标准箍筋
        /// </summary>
        /// <param name="mBarMark"></param>
        /// <param name="sBarMark"></param>
        /// <param name="cBarMark"></param>
        /// <param name="diameter"></param>
        /// <param name="quantity"></param>
        /// <param name="shapeConfig"></param>
        /// <param name="a">内侧距离A</param>
        /// <param name="b">内侧距离B</param>
        /// <param name="rr">内半径，默认为0时，按规范取值</param>
        public MRRebarRecord(
            int mBarMark, int sBarMark, string cBarMark, eDB diameter,
            int quantity, eShapeType shapeConfig,
            int a, int c, int rr = 0) : base(mBarMark, sBarMark, cBarMark, diameter, quantity, shapeConfig)
        {
            if (a < 0  || Lx < 0)
            {
                throw new Exception("箍筋结果异常请查询原因！");
            }
            A = a;
            //B = b;
            C = c;
            this.d = PublicEnumItems.GeteDBData(diameter.ToString());
            if (rr == 0)
            {
                r = RebarKnowledge.GetRadiusForSrirrup(diameter);
            }
            else
            {
                r = rr;
            }

            Lx = RebarKnowledge.GetLx(diameter);
            Lx = 288;
            this.Formula = "L=2(A+C)+Lx";

        }

        public override void SetLength()
        {
            //Length=(2 * (A + B) + Lx)*0.001;
            Length = Math.Round((2 * (A  + C) + Lx) * 0.001, 3, MidpointRounding.AwayFromZero);
        }
    }

}
